Skip to content

Conversation

@BoxyUwU
Copy link
Member

@BoxyUwU BoxyUwU commented May 23, 2024

Currently we represent usages of Region parameters via the ReEarlyParam or ReLateParam variants. The ReEarlyParam is effectively equivalent to TyKind::Param and ConstKind::Param (i.e. it stores a Symbol and a u32 index) however it also stores a DefId for the definition of the lifetime parameter.

This was used in roughly two places:

  • Borrowck diagnostics instead of threading the appropriate body_id down to relevant locations. Interestingly there were already some places that had to pass down a DefId manually.
  • Some opaque type checking logic was using the DefId field to track captured lifetimes

I've split this PR up into a commit for generate rote changes to diagnostics code to pass around a DefId manually everywhere, and another commit for the opaque type related changes which likely require more careful review as they might change the semantics of lints/errors.

Instead of manually passing the DefId around everywhere I previously tried to bundle it in with TypeErrCtxt but ran into issues with some call sites of infcx.err_ctxt being unable to provide a DefId, particularly places involved with trait solving and normalization. It might be worth investigating adding some new wrapper type to pass this around everywhere but I think this might be acceptable for now.

This pr also has the effect of reducing the size of EarlyParamRegion from 16 bytes -> 8 bytes. I wouldn't expect this to have any direct performance improvement however, other variants of RegionKind over 8 bytes are all because they contain a BoundRegionKind which is, as far as I know, mostly there for diagnostics. If we're ever able to remove this it would shrink the RegionKind type from 24 bytes to 12 (and with clever bit packing we might be able to get it to 8 bytes). I am curious what the performance impact would be of removing interning of Region's if we ever manage to shrink RegionKind that much.

Sidenote: by removing the DefId the Debug output for Region has gotten significantly nicer. As an example see this opaque type debug print before vs after this PR:
Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0, T, DefId(0:9 ~ impl_trait_captures[aeb9]::foo::'a)_'a/#0])
Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), ['a/#0, T, 'a/#0])

r? @compiler-errors (I would like someone who understands the opaque type setup to atleast review the type system commit, but the rest is likely reviewable by anyone)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 23, 2024
@rustbot
Copy link
Collaborator

rustbot commented May 23, 2024

This PR changes Stable MIR

cc @oli-obk, @celinval, @ouz-a

HIR ty lowering was modified

cc @fmease

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@BoxyUwU BoxyUwU changed the title Remove DefId from EarlyRegionParam Remove DefId from EarlyParamRegion May 24, 2024
@BoxyUwU BoxyUwU force-pushed the remove_defid_from_regionparam branch from eafea35 to 5451787 Compare May 24, 2024 00:13
Copy link
Member

@compiler-errors compiler-errors left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally very happy with this change 👍 ✨

@compiler-errors
Copy link
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 24, 2024
@bors
Copy link
Collaborator

bors commented May 24, 2024

⌛ Trying commit 5451787 with merge 85c5dfc...

@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

🤔 also would like to know why those tests no longer ICE. I might be able to investigate tomorrow if you end up not being able to find out why, just lemme kno

@BoxyUwU
Copy link
Member Author

BoxyUwU commented May 24, 2024

Oh god why does this make tests no longer ICE 😭

@BoxyUwU BoxyUwU force-pushed the remove_defid_from_regionparam branch from 5451787 to 0946cb8 Compare May 24, 2024 00:58
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

@bors try @rust-timer queue

@rust-timer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented May 24, 2024

⌛ Trying commit 0946cb8 with merge 8210bd9...

@bors
Copy link
Collaborator

bors commented May 24, 2024

☀️ Try build successful - checks-actions
Build commit: 8210bd9 (8210bd94475d1cbf00c0dd7bfe0d48e98259bca1)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (8210bd9): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.1% [4.1%, 4.1%] 1
Improvements ✅
(primary)
-0.4% [-0.9%, -0.2%] 43
Improvements ✅
(secondary)
-0.8% [-1.3%, -0.3%] 24
All ❌✅ (primary) -0.4% [-0.9%, -0.2%] 43

Max RSS (memory usage)

Results (secondary -3.7%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-3.7% [-3.7%, -3.7%] 1
All ❌✅ (primary) - - 0

Cycles

Results (primary -1.4%, secondary 0.8%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
8.0% [7.1%, 8.9%] 2
Improvements ✅
(primary)
-1.4% [-2.2%, -0.9%] 8
Improvements ✅
(secondary)
-2.1% [-2.1%, -2.0%] 5
All ❌✅ (primary) -1.4% [-2.2%, -0.9%] 8

Binary size

Results (primary -0.3%, secondary -0.9%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-1.3%, -0.0%] 88
Improvements ✅
(secondary)
-0.9% [-1.6%, -0.0%] 12
All ❌✅ (primary) -0.3% [-1.3%, -0.0%] 88

Bootstrap: 671.784s -> 671.214s (-0.08%)
Artifact size: 315.72 MiB -> 315.68 MiB (-0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 24, 2024
@compiler-errors
Copy link
Member

TODO: I owe Boxy a detailed explanation for the "regression" (tests that ICE -> pass) which I'll have by the end of my day here hopefully. Then we can land this 🎉

@bors bors added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 25, 2024
@compiler-errors
Copy link
Member

thinking emoji

@bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 25, 2024
@bors
Copy link
Collaborator

bors commented May 25, 2024

⌛ Testing commit ed8e436 with merge c154f01...

@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
error: failed retrieving file 'mingw-w64-x86_64-gdb-14.1-1-any.pkg.tar.zst' from mirror.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed retrieving file 'mingw-w64-x86_64-crt-git-11.0.0.r547.g4c8123efb-1-any.pkg.tar.zst' from mirror.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed retrieving file 'mingw-w64-x86_64-libgccjit-13.2.0-3-any.pkg.tar.zst' from mirror.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
warning: too many errors from mirror.msys2.org, skipping for the remainder of this transaction
error: failed retrieving file 'mingw-w64-x86_64-python-3.11.7-1-any.pkg.tar.zst.sig' from mirror.umd.edu : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed to commit transaction (unexpected error)
 mingw-w64-x86_64-gcc-13.2.0-3-any downloading...
 mingw-w64-x86_64-python-3.11.7-1-any downloading...
 mingw-w64-x86_64-gcc-ada-13.2.0-3-any downloading...

@bors
Copy link
Collaborator

bors commented May 25, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 25, 2024
@BoxyUwU
Copy link
Member Author

BoxyUwU commented May 25, 2024

CI is broken, see this zulip thread. I guess we should just wait a little bit...

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 25, 2024
@compiler-errors
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented May 26, 2024

📌 Commit ed8e436 has been approved by compiler-errors

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented May 26, 2024

🌲 The tree is currently closed for pull requests below priority 100. This pull request will be tested once the tree is reopened.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 26, 2024
@BoxyUwU
Copy link
Member Author

BoxyUwU commented May 26, 2024

5th times the charm lol :")

@bors
Copy link
Collaborator

bors commented May 27, 2024

⌛ Testing commit ed8e436 with merge fec98b3...

@bors
Copy link
Collaborator

bors commented May 27, 2024

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing fec98b3 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label May 27, 2024
@bors bors merged commit fec98b3 into rust-lang:master May 27, 2024
@rustbot rustbot added this to the 1.80.0 milestone May 27, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (fec98b3): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.4% [-0.9%, -0.2%] 48
Improvements ✅
(secondary)
-0.8% [-2.0%, -0.3%] 19
All ❌✅ (primary) -0.4% [-0.9%, -0.2%] 48

Max RSS (memory usage)

Results (primary -0.9%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.1% [1.1%, 1.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.3% [-2.1%, -0.8%] 5
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.9% [-2.1%, 1.1%] 6

Cycles

Results (primary -1.4%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-1.4% [-1.6%, -1.3%] 5
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -1.4% [-1.6%, -1.3%] 5

Binary size

Results (primary -0.3%, secondary -0.9%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.3% [-1.3%, -0.0%] 80
Improvements ✅
(secondary)
-0.9% [-1.6%, -0.0%] 12
All ❌✅ (primary) -0.3% [-1.3%, -0.0%] 80

Bootstrap: 669.538s -> 668.124s (-0.21%)
Artifact size: 315.56 MiB -> 315.55 MiB (-0.00%)

@rustbot rustbot removed the perf-regression Performance regression. label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants